﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Enterprise.Model.User;
using Enterprise.Service.User;
using Enterprise.Service.Department;
using Enterprise.Infrastructure;
using Enterprise.Control;
namespace Enterprise.UI.Web.Modules.User
{
    public partial class Disp : System.Web.UI.Page
    {
        int Id = (int)Utility.sink("Id", Utility.MethodType.Get, 0, 0, Utility.DataType.Int);
        int DeptId = (int)Utility.sink("DeptId", Utility.MethodType.Get, 0, 0, Utility.DataType.Int);
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                OnStart();
            }
        }

        private void OnStart()
        {
            OnCommand();
            OnBindData();
        }

        private void OnCommand()
        {
            //添加操作按钮
            CreateBT.AddButton("a.gif", "重置密码", "Manage.aspx?Cmd=Restore&Id=" + Id, Utility.PopedomType.A, HeadMenu1);
            CreateBT.AddButton("edit.gif", "修改", "Manage.aspx?Cmd=Edit&Id=" + Id, Utility.PopedomType.Edit, HeadMenu1);
            CreateBT.AddButton("delete.gif", "删除", "DelData('Manage.aspx?Cmd=Delete&Id=" + Id+"')", Utility.PopedomType.Delete, HeadMenu1);
            CreateBT.AddButton("back.gif", "返回", "List.aspx?Id="+DeptId, Utility.PopedomType.List, HeadMenu1);
        }

        private void OnBindData()
        {
            UserService uService = new UserService();
            var user = uService.UserDisp(Id);
            if (user != null)
            {
                lb_Name.Text = user.UNAME;
                lb_LoginName.Text = user.ULOGINNAME;
                lb_Sex.Text = user.USEX;
                lb_Dept.Text = DepartmentService.GetDepartMentName(user.DEPTID);
                lb_BirthDay.Text = user.UBIRTHDAY.ToShortDateString();
                lb_Hw.Text = user.UHWPHONE;
                lb_Gn.Text = user.UGNPHONE;
                lb_Sipc.Text = user.SIPCEMAIL;
                lb_Others.Text = user.OTHEREMAIL;
            }
        }

    }
}